﻿Imports System.Data.SqlClient

Public Class MSSQL
    Private Const ConnString = "Data Source=GEBRUIK-34W7PDG;Initial Catalog=db_MSS;User Id=sa;Password=ZFzf17;"
    Private SQLConn As New SqlConnection()
    Private SQLCmd As New SqlCommand()

    Public Function OpenRS(ByVal Query As String) As SqlDataReader
        SQLConn.ConnectionString = ConnString
        SQLConn.Open()

        SQLCmd.Connection = SQLConn
        SQLCmd.CommandText = Query
        Return SQLCmd.ExecuteReader
    End Function

    Public Sub Execute(ByVal Query As String)
        SQLConn.ConnectionString = ConnString
        SQLConn.Open()

        SQLCmd.Connection = SQLConn
        SQLCmd.CommandText = Query
        SQLCmd.ExecuteNonQuery()
        SQLCmd.Dispose()
    End Sub

    Public Sub Close()
        On Error Resume Next
        SQLConn.Close()
        SQLCmd.Dispose()
        GC.Collect()
    End Sub
End Class
